<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<script language="JavaScript" type="text/JavaScript">
		window.onload = function()
		{
			document.getElementById("submit").style.display = 'none';
			document.getElementById("aircraft").disabled = true;
			if('${userSession}' ==  "" || '${userSession}' ==  null)
				self.location = "login.jsp";
		}
		
		function getFlight()
		{
			open("flightList.jsp","","width=900,height=400,scrollbars,resizable,toolbar,status");
		}
		
		function setFlight(alid, aircraft, date)
		{
			document.getElementById("aircraft").value = aircraft;
			document.getElementById("air_craft").value = aircraft;
			document.getElementById("alid").value = alid;
			document.getElementById("date").value = date;
			window.focus();
		}
		
		function isEmpty(str)
		{
			if(str == null || str == "")
				return true;
			else
				return false;
		}

		function validatePage()
		{
			var passport = document.getElementsByName("passport")[0].value;
			var nationality = document.getElementsByName("nationality")[0].value;
			var aircraft = document.getElementsByName("air_craft")[0].value;

			if(isEmpty(passport))alert("Please enter Passport Number.");
			else if(isEmpty(nationality))alert("Please enter your Nationality.");
			else if(isEmpty(aircraft))alert("Please select a Flight.");
			else document.getElementById("submit").click();
		}
		
	</script>
	<body>
		<form method="post" action="bookATicket">
			<h1>New Ticket</h1>
			<table>
	
				<tr><td>PassPort Number: </td>
				<td><input type="text" name="passport" size="6" maxlength="6" value="${customer.passport}"/></td></tr>
				<tr><td>Nationality: </td>
				<td><input type="text" name="nationality" size="20" maxlength="20" value="${customer.nationality}"/></td></tr>
				<tr><td>Flight: </td>
				<td><input id="aircraft" type="text" name="aircraft" size="9" maxlength="9"/></td>
				<td><a style="color:blue;" href="javascript:getFlight();">Get Flight</a></td></tr>
				<tr><td>Status: </td>
				<td>
					<select name="status">
						<option value="Ticket Issued">Ticket Issued</option>
					  	<option value="Ticket Blocked">Ticket Blocked</option>
					  	<option value="New Booking">Pending</option>
					</select>
				</td>
			</table><br><br>

			<input type="button" value="Book Ticket" onclick="validatePage();"/>	
			<input id="submit" type="submit" name="submit" value="submit"/>
			
			<input id="alid" type="hidden" name="alid"/>
			<input id="date" type="hidden" name="date"/>
			<input id="air_craft" type="hidden" name="air_craft"/>
			<input type="hidden" name="cid" value="${sessionScope.customer.cid}"/>
		</form>
	</body>
</html>
